<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>后台管理</title>
    <!-- Bootstrap core CSS -->
    <link th:href="@{/webjars/bootstrap/4.4.1-1/css/bootstrap.css}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
    <link th:href="@{/iconfont/iconfont.css}" rel="stylesheet">
    <link href="asserts/css/from-table.css" th:href="@{/asserts/css/from-table.css}" rel="stylesheet">
    <style type="text/css">
        /* Chart.js */

        @-webkit-keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        @keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        .info {
            float: left;
        }

        .pagination {
            float: right;
        }

    </style>
</head>

<body>
<!--引入抽取的topbar-->
<!--模板名：会使用thymeleaf的前后缀配置规则进行解析-->
<div th:replace="commons/bar::topbar"></div>

<div class="container-fluid">
    <div class="row">
        <!--引入侧边栏-->
        <div th:replace="commons/bar::#sidebar(activeUri='contracts')"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <form class="navbar-form navbar-right search-range-two" th:action="@{/consearch}">
                <div class="input-group mb-3">
                    <input name="name" type="text" class="form-control info-box" placeholder="名字" th:value="${name}" >
                    <input name="CWorkId" type="text" class="form-control info-box" placeholder="工号:ce10****" th:value="${CWorkId}">
                    <div class="input-group-append">
                        <button class="btn btn-success query" type="submit">
                            <span class="iconfont icon&#45;&#45;search1"></span>
                        </button>
                    </div>
                </div>

            </form>

            <h2 class="add"><a class="btn btn-sm btn-success" href="contract" th:href="@{/contract}">添加</a></h2>

            <div class="table-responsive">
                <table class="table table-striped table-sm table-bordered" id="ct_table">
                    <thead>
                    <tr>
                        <th>合同编号</th>
                        <th>员工工号</th>
                        <th>员工姓名</th>
                        <th>合同期限</th>
                        <th>合同起始日期</th>
                        <th>合同终止日期</th>
                        <th>合同内容</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="contract:${pageInfo.list}">
                        <td>[[${contract.CId}]]</td>
                        <td>[[${contract.CWorkId}]]</td>
                        <td>[[${contract.emp.name}]]</td>
                        <td>[[${contract.contractTerm}]]</td>
                        <td>[[${#dates.format(contract.beginContract, 'yyyy-MM-dd')}]]</td>
                        <td>[[${#dates.format(contract.endContract, 'yyyy-MM-dd')}]]</td>
                        <td><a th:id="${contract.CId}"  th:href="@{/contract/fileUp/}+${contract.CId}" }>上传文件</a>
                            <a id="download" th:href="@{/download(filename=${contract.contractContent})}" >
                                <label th:type="button" th:style="${contract.contractContent==null}?'display:none':''">下载文件</label>
                            </a>
                        </td>
                        <td>
                            <a class="btn btn-sm btn-primary" th:href="@{/contract/}+${contract.CId}">编辑</a>
                            <button th:id="${contract.CId}" th:attr="del_uri=@{/contract/}+${contract.CId}"
                                    class="btn btn-sm btn-danger deleteBtn">删除
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>

                <div class="msg">
                    <p th:text="${info}" th:if="${not #strings.isEmpty(info)}"></p>
                </div>
                <p class="info">
                    当前第 <span th:text="${pageInfo.pageNum}"></span> 页,总共 <span
                        th:text="${pageInfo.pages}"></span> 页,共 <span
                        th:text="${pageInfo.total}"></span> 条记录
                </p>
                <ul class="pagination" th:if="${name}==null">
                    <li class="page-item"><a class="page-link" th:href="@{/contracts}">首页</a></li>
                    <li class="page-item"><a class="page-link"
                                             th:href="@{/contracts(pageNum=${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1)}">上一页</a>
                    </li>
                    <li class="page-item"><a class="page-link"
                                             th:href="@{/contracts(pageNum=${pageInfo.hasNextPage}?${pageInfo.nextPage}:${pageInfo.pages})}">下一页</a>
                    </li>
                    <li class="page-item"><a class="page-link" th:href="@{/contracts(pageNum=${pageInfo.pages})}">尾页</a>
                    </li>
                </ul>
                <ul class="pagination" th:if="${name}!=null">
                    <li class="page-item"><a  class="page-link" th:if="${pageInfo.hasPreviousPage}" th:href="@{${url}(pageNum=${pageInfo.navigateFirstPage},name=${name},CWorkId=${CWorkId})}">首页</a></li>
                    <li class="page-item"><a  class="page-link" th:if="${pageInfo.hasPreviousPage}" th:href="@{${url}(pageNum=${pageInfo.prePage},name=${name},CWorkId=${CWorkId})}">上一页</a></li>
                    <li class="page-item"><a  class="page-link" th:if="${pageInfo.hasNextPage}" th:href="@{${url}(pageNum=${pageInfo.nextPage},name=${name},CWorkId=${CWorkId})}">下一页</a></li>
                    <li class="page-item"><a  class="page-link" th:if="${pageInfo.hasNextPage}" th:href="@{${url}(pageNum=${pageInfo.navigateLastPage},name=${name},CWorkId=${CWorkId})}">末页</a></li>
                </ul>
            </div>
        </main>
        <form id="deleteContractForm" method="post">
            <input type="hidden" name="_method" value="delete"/>
        </form>
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" th:src="@{/webjars/jquery/3.5.0/jquery.js}"></script>
<script type="text/javascript">
    $(".deleteBtn").click(function () {
        var id = $(this).attr("id");
        if (confirm("确定要删除编号为"+id+"的合同数据吗?")){
            //删除当前合同的
            $("#deleteContractForm").attr("action", $(this).attr("del_uri")).submit();
            return true;
        }else {
            return false;
        }

    });


</script>
</body>
</html>